from multiprocessing import Process

a = 100

def add():
    print('子进程1开始')
    global a
    a = a + 30
    print(f'a: {a}, 子进程1结束')

def sub():
    print('子进程2开始')
    global a
    a = a - 50
    print(f'a: {a}, 子进程2结束')


if __name__ == '__main__':
    print('父进程开始, a:', a)
    p1 = Process(target=add)
    p2 = Process(target=sub)
    p1.start()
    p2.start()
    p1.join()
    p2.join()

    print('最后, a:', a)
    print('主进程结束')

# 进程间的数据不能共享，通过才能queue共享